package org.ccay.async.dispatcher.impl;

import javax.inject.Named;

import org.ccay.async.AsyncMessage;
import org.ccay.async.IMessageProcessor;
import org.ccay.async.dispatcher.EventArgsPack;
import org.ccay.core.dispatcher.EventUtil;
import org.ccay.core.exception.ApplicationException;

/**
 * 异步事件消息处理器
 * 
 * 
 * @since 2012-7-4
 */
@Named("asyncEventMessageProcesser")
public class AsyncEventMessageProcesser implements IMessageProcessor {

	/* (non-Javadoc)
	 * @see org.ccay.async.IMessageProcessor#process(org.ccay.async.AsyncMessage)
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public void process(AsyncMessage message) throws ApplicationException {
		EventArgsPack args = (EventArgsPack) message.getContent();		
		EventUtil.dispatch(args.getHandlerClass(), this ,args.getEventArgs(), args.isIgnoreError());
	}

}
